#pragma once

namespace singleton {
    
/// @brief 饿汉式单例. 类一旦加载就创建一个单例
/// 优点: 线程安全
/// 缺点: 丢失延迟实例化带来的节约资源的好处
class HungrySingleton {
public:
    HungrySingleton* getInstance() { return instance_; }

private:
    HungrySingleton() {}
    static HungrySingleton* instance_;
};

HungrySingleton* HungrySingleton::instance_ = new HungrySingleton();

} // namespace singleton
